Skip to main content

QLearner Class

Description:

  A class for creating QLearner objects.

Usage:

local ML = require("ML")
local qLearner = ML.QLearner()

pack

Type: Function.

Description:

  Construct a state from given hints and condition values.

Signature:

pack: function(self: QLearnerClass, hints: {integer}, values: {integer}): --[[state]] integer

Parameters:

ParameterTypeDescription
hints{integer}Representing the byte length of provided values.
values{integer}The condition values as discrete values.

Returns:

Return TypeDescription
integerThe packed state value.

unpack

Type: Function.

Description:

  Deconstruct a state from given hints to get condition values.

Signature:

unpack: function(self: QLearnerClass, hints: {integer}, state: integer): {integer}

Parameters:

ParameterTypeDescription
hints{integer}Representing the byte length of provided values.
stateintegerThe state integer to unpack.

Returns:

Return TypeDescription
{integer}The condition values as discrete values.

__call

Type: Metamethod.

Description:

  Create a new QLearner object with optional parameters for gamma, alpha, and maxQ.

Signature:

metamethod __call: function(
self: QLearnerClass,
gamma?: number --[[0.5]],
alpha?: number --[[0.5]],
maxQ?: number --[[100.0]]
): QLearner

Parameters:

ParameterTypeDescription
gammanumberThe discount factor for future rewards. Defaults to 0.5.
alphanumberThe learning rate for updating Q-values. Defaults to 0.5.
maxQnumberThe maximum Q-value. Defaults to 100.0.

Returns:

Return TypeDescription
QLearnerThe newly created QLearner object.